package com.ruoyi.weiriya.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.common.core.domain.entity.WVehicle;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 车辆信息Mapper接口
 * 
 * @author lynn
 * @date 2023-08-01
 */
public interface WVehicleMapper extends BaseMapper<WVehicle>
{

    @Select("SELECT v.*,a.name as area_name, m.real_name, m.nick_name, m.card_no, m.user_name,m.member_type,m.vip_type, vct.type_value as vehicle_charge_type_value,vnct.type_value as vehicle_non_charge_type_value " +
            "FROM w_vehicle v " +
            "LEFT JOIN w_member m on m.id = v.member_id " +
            "LEFT JOIN w_area a on a.id = m.area_id " +
            "LEFT JOIN w_vehicle_charge_type vct on vct.id = v.vehicle_charge_type_id " +
            "LEFT JOIN w_vehicle_non_charge_type vnct on vnct.id = v.vehicle_non_charge_type_id ${ew.customSqlSegment}")
    List<WVehicle> getList(@Param(Constants.WRAPPER) QueryWrapper<WVehicle> queryWrapper);

    @Select("SELECT v.*,a.name as area_name, m.real_name, m.nick_name, m.card_no, m.user_name,m.member_type,m.vip_type, vct.type_value as vehicle_charge_type_value,vnct.type_value as vehicle_non_charge_type_value " +
            "FROM w_vehicle v " +
            "LEFT JOIN w_member m on m.id = v.member_id " +
            "LEFT JOIN w_area a on a.id = m.area_id " +
            "LEFT JOIN w_vehicle_charge_type vct on vct.id = v.vehicle_charge_type_id " +
            "LEFT JOIN w_vehicle_non_charge_type vnct on vnct.id = v.vehicle_non_charge_type_id " +
            "WHERE v.id = #{id}")
    WVehicle getWVehicleById(String id);

    @Select("SELECT v.*,a.name as area_name, m.real_name, m.nick_name, m.card_no, m.user_name,m.member_type,m.vip_type, vct.type_value as vehicle_charge_type_value,vnct.type_value as vehicle_non_charge_type_value " +
            "FROM w_vehicle v " +
            "LEFT JOIN w_member m on m.id = v.member_id " +
            "LEFT JOIN w_area a on a.id = m.area_id " +
            "LEFT JOIN w_vehicle_charge_type vct on vct.id = v.vehicle_charge_type_id " +
            "LEFT JOIN w_vehicle_non_charge_type vnct on vnct.id = v.vehicle_non_charge_type_id " +
            "WHERE v.member_id = #{memberId}")
    WVehicle getWVehicleByMemberId(String memberId);
}
